#include "TreeNode.h"
const int SIZE  = 2000;

template <typename Type>
class Stack
{
public:
	Stack()
	{
		nodeArray = new Type[SIZE];
		currentPointer = 0;
	}

	~Stack()
	{
		delete[] nodeArray;
	}

	bool isEmpty()
	{
		return currentPointer == 0;
	}

	void push(const Type&  dat )
	{
		if(currentPointer == SIZE -1)
		{
			std::cout <<"The stack is full"<<std::endl;
			return;
		}

		nodeArray[currentPointer++] = dat;
	}

	Type pop()
	{
		if(currentPointer > 0)
		{
			return nodeArray[--currentPointer];
		}
		else
		{
			std::cout <<"The stack is empty now, NULL element returned."<<std::endl;
			exit(-1);//return *(Type*)NULL;
		}

	}



private:
	Type* nodeArray;
	//Points to next available empty position.
	int currentPointer;
};
